﻿namespace LogicStudio.Framework.UI.Utilidades
{
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    using System.ServiceModel.DomainServices.Client;

    public class EntityValidator
    {
        private static EntityValidationResult Validar(object objeto)
        {
            var validationResults = new List<ValidationResult>();
            var vc = new ValidationContext(objeto, null, null);
            Validator.TryValidateObject(objeto, vc, validationResults);

            return new EntityValidationResult(validationResults);
        }

        public EntityValidationResult Validate(object objeto)
        {
            return Validar(objeto);
        }

        public EntityValidationResult Validate(Entity entity)
        {
            return Validar(entity);
        }
    }
}